package org.provider.user.server;

import org.common.enums.ExchangeEnum;
import org.common.enums.QueueEnum;
import org.provider.rabbitmq.QueueMessageService;
import org.provider.user.entity.UserEntity;
import org.provider.user.jpa.UserJPA;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
*@author LSY
*Time: 2018年12月29日上午9:29:44
*
*
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class UserService {

	@Autowired
	private UserJPA userJPA;
	@Autowired
	private QueueMessageService queueMessageService;
	
	public Long save(UserEntity userEntity) throws Exception{
		userJPA.save(userEntity);
		queueMessageService.send(userEntity.getId(), ExchangeEnum.USER_REGISTER, QueueEnum.USER_REGISTER);
		return userEntity.getId();
	}
}
